<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
    <title>登录_插件</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #4a90e2, #5a67d8);
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            margin: 0;
        }

        .card {
            background: rgba(255, 255, 255, 0.95);
            padding: 2.5rem;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.15);
            width: 350px;
            text-align: center;
        }

        h1 {
            color: #2d3748;
            margin-bottom: 2rem;
            font-size: 1.8rem;
        }

        .input-group {
            margin-bottom: 1.5rem;
            text-align: left;
        }

        label {
            display: block;
            color: #4a5568;
            margin-bottom: 0.5rem;
            font-weight: 500;
        }

        input {
            width: 100%;
            padding: 0.8rem;
            border: 2px solid #e2e8f0;
            border-radius: 8px;
            font-size: 1rem;
            transition: border-color 0.3s ease;
        }

        input:focus {
            outline: none;
            border-color: #4a90e2;
        }

        button {
            background: #4a90e2;
            color: white;
            padding: 1rem 2rem;
            border: none;
            border-radius: 8px;
            font-size: 1rem;
            cursor: pointer;
            transition: background 0.3s ease;
            width: 100%;
        }

        button:hover {
            background: #357abd;
        }

        /* 自定义模态框样式 */
        .modal {
            display: none; /* 默认隐藏 */
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            justify-content: center;
            align-items: center;
        }

        .modal-content {
            background: white;
            padding: 2rem;
            border-radius: 10px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
            text-align: center;
            max-width: 300px;
        }

        .modal-content h2 {
            margin-bottom: 1rem;
            color: #2d3748;
        }

        .modal-content p {
            color: #4a5568;
            margin-bottom: 1.5rem;
        }

        .modal-content button {
            background: #4a90e2;
            color: white;
            padding: 0.5rem 1rem;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background 0.3s ease;
        }

        .modal-content button:hover {
            background: #357abd;
        }
    </style>
</head>
<body>
    <div class="card">
        <h1>欢迎使用登录插件</h1>
        <form id="loginForm" action="#" method="post">
            <div class="input-group">
                <label>用户名</label>
                <input type="text" name="username" required>
            </div>
            <div class="input-group">
                <label>密码</label>
                <input type="password" name="password" required>
            </div>
            <button type="submit">登录</button>
        </form>
    </div>

    <!-- 自定义模态框 -->
    <div id="customModal" class="modal">
        <div class="modal-content">
            <h2>提示</h2>
            <p>简单的登陆插件演示完毕<br>其它类型的插件可以自行参考登陆插件源码实现.</p>
            <button id="closeModal">关闭</button>
        </div>
    </div>

    <script>
        // 确保 DOM 加载完成后再绑定事件
        document.addEventListener('DOMContentLoaded', function() {
            // 获取表单元素
            const form = document.getElementById('loginForm');
            // 获取模态框元素
            const modal = document.getElementById('customModal');
            // 获取关闭按钮元素
            const closeModalButton = document.getElementById('closeModal');

            // 监听表单的提交事件
            form.addEventListener('submit', function(event) {
                // 阻止表单的默认提交行为
                event.preventDefault();

                // 显示自定义模态框
                modal.style.display = 'flex';
            });

            // 监听关闭按钮的点击事件
            closeModalButton.addEventListener('click', function() {
                // 隐藏模态框
                modal.style.display = 'none';
            });

            // 点击模态框外部时关闭模态框
            modal.addEventListener('click', function(event) {
                if (event.target === modal) {
                    modal.style.display = 'none';
                }
            });
        });
    </script>
</body>
</html>